package com.zkthink.ceres.order.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** 退款理由
 * @author JustArgo 2020/5/14 23:58
 * @return
 */
@Getter
public enum ReturnMoneyReasonEnum {

    BUY_WRONG(1,"拍错/多拍/不想要了"),
    NOT_RECEIVE(2,"快递一直未送到"),
    NOT_SEND(3,"未按约定时间发货"),
    NOT_LOGISTICS_RECORD(4,"快递无跟踪记录"),
    EMPTY_PACKAGE(5,"空包裹/少货"),
    OTHER(6,"其他"),
    ;

    private int code;

    private String desc;

    ReturnMoneyReasonEnum(int code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static String findDescByCode(int code){
        ReturnMoneyReasonEnum[] reasonEnums = ReturnMoneyReasonEnum.values();
        for(ReturnMoneyReasonEnum reasonEnum:reasonEnums){
            if(reasonEnum.getCode()==code){
                return reasonEnum.getDesc();
            }
        }
        return "原因未知";
    }

    public static List<Map<String,Object>> generateList(){
        ReturnMoneyReasonEnum[] reasonEnums = ReturnMoneyReasonEnum.values();
        List<Map<String,Object>> reasonList = new ArrayList<>();
        for(ReturnMoneyReasonEnum reasonEnum:reasonEnums){
            Map<String,Object> map = new HashMap<String,Object>();
            map.put("code",reasonEnum.getCode());
            map.put("desc",reasonEnum.getDesc());
            reasonList.add(map);
        }
        return reasonList;
    }

}
